<template>
  <div>
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图 -->
    <el-card>
      <el-table :data="tableData" stripe border style="width: 100%">
        <el-table-column prop="id" label="" width="180"> </el-table-column>
        <el-table-column prop="authName" label="权限名称" width="180">
        </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>
        <el-table-column prop="address" label="权限等级">
          <template slot-scope="scope">
            <el-button
              plain
              disabled
              size="small"
              :type="color(scope.row.level)"
              >{{ grade(scope.row.level) }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
    }
  },
  created() {
    this.render()
  },
  methods: {
    async render() {
      const res = await this.$http({
        url: 'rights/list',
        method: 'GET',
      })
      this.tableData = res.data.data
    },
    grade(level) {
      if (level == '0') {
        return '一级'
      } else if (level == '1') {
        return '二级'
      } else {
        return '三级'
      }
    },
    color(level) {
      if (level == '0') {
        return 'primary'
      } else if (level == '1') {
        return 'success'
      } else {
        return 'warning'
      }
    },
  },
}
</script>

<style lang="less" scoped></style>
